<template>
	<!-- 添加弹框 -->
	<el-dialog  title="" size='tiny' :visible.sync="dialogTableVisible" class="wrap" @close="cancel" :close-on-click-modal="false">
		<i class="el-icon-close close" @click="cancel" style="color: white;"></i>
	    <div class="bt">班级添加管理</div>
		<el-form label-width="100px" class="form">
			<el-form-item label="分校课程">
				<el-input type="" v-model="vfxkcidmc" placeholder="请选择分校课程" class="select-block1"  icon="add":readonly="true"></el-input>
				<el-button size="small" @click="showwp()" class="select-block2" >选择</el-button>
			</el-form-item>
			<el-form-item label="教材">
				<el-input type="" v-model="vjcidmc" placeholder="请选择教材名称" class="select-block1" icon="add"  :readonly="true"></el-input>
				<el-button size="small" @click="showjc()" class="select-block2">选择</el-button>
			</el-form-item>
			<el-form-item label="老师">
				<el-select v-model="vlsid" class="select-block">
					<el-option :label="v.mc" :value="v.id" v-for="v in comboxlist"></el-option>
				</el-select></el-input>
			</el-form-item>
			<el-form-item label="班级名称">
				<el-input v-model="vmc" placeholder="请输入名称" icon="add"  class="select-block"></el-input>
			</el-form-item>
			<el-form-item label="开班时间段">
				<el-input v-model="vkbsjd" placeholder="请输入名称" icon="add"  class="select-block"></el-input>
			</el-form-item>
			<!-- <el-form-item label="已排课时">
				<el-input v-model="vypks" placeholder="请输入已排课时" icon="add"  class="select-block"></el-input>
			</el-form-item> -->
			<el-form-item label="开班日期">
				<el-date-picker  v-model="vbtime"  type="date" class="select-block" placeholder="选择日期" @keyup.enter.native="search">  </el-date-picker>
			</el-form-item>
			
			<el-form-item label="备注">
 				<el-input v-model="vnote" type="textarea"  :rows="4"  placeholder="请输入" class="select-block"></el-input>
 		</el-form-item>

		</el-form>

		<!--<div class="input-block">
			<span>册id：</span>
			<el-input v-model="vcid" placeholder="请输入册id" icon="add" class="input"></el-input>
		</div>-->

		<!--<div class="input-block">
			<span>创建cj/转入zr/转出zc：</span>
			<el-input v-model="vlx" placeholder="请输入创建cj/转入zr/转出zc" icon="add" class="input"></el-input>
		</div>-->
		<!--<div class="input-block">
			<span>已排课时：</span>
			<el-input v-model="vypks" placeholder="请输入已排课时" icon="add" class="input"></el-input>
		</div>-->

		<el-button type="info" class="submit" @click="submit">保存</el-button>
		<PayArticle class="wpfl1" @jcarticle="jcarticleed"  @close="jcarticlecancel" v-if="showarticle"></PayArticle>
		<Kschoose class="wpfl" @wpchoose="wpchooseed" @close="wpchoosecancel" v-if="showchoselist"></Kschoose>
	</el-dialog>
</template>
<script type="text/javascript">
	import Kschoose from '../../manage/kssz/kschoose'
	import PayArticle from './pay-articlejc'
	import qs from 'qs'
	export default {
		components: { Kschoose, PayArticle },
		data() {
			return {
				showchoselist: false,
				showarticle: false,
				vfxkcid: '',
				vfxkcidmc: '',
				vmc: '',
				vbtime:'',
				vlsid: '',
				vcid: '',
				vjcid: '',
				vjcidmc: '',
				vypks:'',
				vlx: '',
				vypks: '',
				vnote:'',
				xzls:'',
				vkbsjd:'',
				comboxlist: [],
				dialogTableVisible: true,
				xzlsList: []
			}
		},
		created() {
			this.getcomboxlist();
			this.getxzlsList();
		},
		methods: {
			getxzlsList () {
				var logininfo = JSON.parse(localStorage.logininfo);
					this.axios.get( this.$store.state.api + 'ls/xzxzls', {
							params: {
								yhid: logininfo.id,
								xxid:logininfo.xxid
							}
					})
					.then( res => {
							console.log(res)
							this.xzlsList = res.data.data;
					}).catch( res => {
							console.log(res)
					})
			},
			submit() {
				//检测
				this.$store.state.loading = true;
				if(!this.vfxkcid) {
					this.$message.warning('请选择分校课程');
					this.$store.state.loading = false;
					return;
				}
				var time1 = this.$.getLocalTimeNo0(Date.parse(this.vbtime));
				var logininfo = JSON.parse(localStorage.logininfo);
				var params3 = qs.stringify({
					mc: this.vmc,
					yhid: logininfo.id,
					xxid: logininfo.xxid,
					lsid: this.vlsid,
					cid: this.vcid,
					jcid: this.vjcid,
					ypks:this.vypks,
					fxkcid: this.vfxkcid,
					kbsjd:this.vkbsjd,
					yjkbrq:time1,
					note:this.vnote

					// xzid:this.xzls,
					// lx: 'cj',
					// ypks: '0',
					// kbrq:time1
				});
				//执行
				this.axios.post(this.$store.state.api + 'ysbj/insert', params3)
					.then(res => {
						if(res.data.code == 1) {
							this.$emit('close', { type: 'add', cancel: false });
							this.$store.state.loading = false;
						} else {
							this.$emit('close', { type: 'add', cancel: false });
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.warning("服务器繁忙，请重试");
						//this.$emit('close', { type: 'add', cancel: false });
						this.$store.state.loading = false;
					})
			},
			showwp() {
				this.showchoselist = true;
			},
			showjc() {
				this.showarticle = true;
			},
			wpchooseed(josndata) {
				this.vfxkcidmc = josndata.kcmc;
				this.vfxkcid = josndata.fxkcid;

				this.showchoselist = false;
			},
			jcarticleed(josndata) {
			    this.vcid = josndata.cid;
			    this.vjcid = josndata.jcid;
			    this.vjcidmc = josndata.jcidmc;
				this.showarticle = false;
			},
			wpchoosecancel() {
				this.showchoselist = false;
			},
			jcarticlecancel() {
				this.showarticle = false;
			},
			cancel() {
				this.$emit('close', { type: 'add', cancel: true })
			},
			getcomboxlist() {
				var logininfo = JSON.parse(localStorage.logininfo);
				this.searchLoading = true;
				this.axios.get(this.$store.state.api + 'ls/getlslist', {
					params: {
						yhid: logininfo.id,
						xxid: logininfo.xxid
					}
				}).then(res => {
					console.log(res)
					let data = res.data.data;
					let list = data.list;
					this.comboxlist = list;
					console.log(this.comboxlist)
				}).catch(res => {
					console.log(res)
					this.searchLoading = false;
				})
			}
		}
	}
</script>
<style lang="less" scoped >
	.wrap {
		.row{
			height:50px;
			line-height: 50px;
		}
		.bt{
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top: 0;
			left: 0;
			// margin-top: -70px;
			background: #50BFFF;
			// margin-left: -20px;
			// margin-bottom: 20px;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
		.close{
				z-index: 10;
				position: absolute;
		}
		.input-block {
			margin-bottom: 20px;
			text-align: center;
		}
		.input {
			width:280px;
			display: inline-block;
			margin-left: 10px;
		}
		.input1 {
			width: 210px;
			display: inline-block;
			margin-left: 10px;
		}
		.input-block span {
			display: inline-block;
			width: 70px;
			text-align: right;
		}
		.submit {
			width: 120px;
			display: block;
			margin: 0 auto;
			margin-top: 20px;
		}
		.wpfl {
			background: #fff;
			position: absolute;
			top: 5px;
			left: 5px;
		}
		.wpfl1 {
			width: 130%;
			background: #fff;
			position: absolute;
			top: 5px;
			left: -66px;
		}
		.form {
			text-align: left;
			margin-top: 10px;
			.select-block {
				width: 85%;
				display: block;
			}
			.select-block1 {
				width: 68%;
				// display: block;
			}
		}
	}
</style>
